package xyz.fivefaith.tool.mybatis.injector;

import lombok.Setter;
import lombok.experimental.Accessors;

import java.util.function.Predicate;

/**
 * @author zhaoanchi
 * @version 1.0
 * @since 2023-09-18 16:08
 */
@Setter
public abstract class AbstractPredicateMethod<T> extends AbstractFaithMethod {

    /** 字段筛选条件 */
    @Accessors(chain = true)
    protected Predicate<T> predicate;

    /**
     * @param name 方法名
     * @param predicate 筛选条件
     * @since 3.5.0
     */
    protected AbstractPredicateMethod(String methodName, Predicate<T> predicate) {
        super(methodName);
        this.predicate = predicate;
    }

    /**
     * @param methodName 方法名
     * @since 3.5.0
     */
    protected AbstractPredicateMethod(String methodName) {
        super(methodName);
    }

    /**
     * 获取是否开启逻辑删除, 默认不开启
     *
     * @return 是否开启逻辑删除
     */
    protected abstract Predicate<T> getPredicate();
}
